﻿using System;
using System.Collections.Generic;
using System.Linq;


namespace Monitor.Models.Json
{
    public class Mesuring
    {
        public Int64 MesuringId { get; set; }
        public Int64 TimeOut { get; set; }
    }
    public class CarOutput
    {
        public Int64 CarId { get; set; }
        public string SerialNumber { get; set; }
        public Int64 Type { get; set; }
        public string TypeOfCar { get; set; }
        public Int64 BackId { get; set; }
        public Int64 BackSerialNumber { get; set; }
        public Int64 OperationOrganization { get; set; }
        public string Organization { get; set; }
        public Dictionary<Int64, Int64> Mesuring { get; set; }
        public DateTime Date { get; set; }
        public CarOutput(){}
        public CarOutput(Repository.DataRepository.LinqModel.Car queryModelCar)
        {
            CarId = queryModelCar.CarId;
            BackId = queryModelCar.BakId;
            BackSerialNumber =
                queryModelCar.BakLink.SerialNumber;
            Date = queryModelCar.Date;
            Type = queryModelCar.Type;
            TypeOfCar =
                queryModelCar.ClassifType.FullName;
            Mesuring =
                queryModelCar.ListOfParam.ToDictionary(
                    n => n.ParamId, n => n.Period);
            SerialNumber = queryModelCar.SerialNumber;
            OperationOrganization =
                queryModelCar.OperationOrganization;
            Organization =
                queryModelCar.ClassifOrganization.
                    FullName;
        }

    }
    public class CarInput
    {
        public Int64? Id { get; set; }
        public string SerialNumber { get; set; }
        public Int64? Type { get; set; }
        public Int64? BackId { get; set; }
        public Int64? OperationOrganization { get; set; }
        public DateTime? Date { get; set; }
        public Mesuring[] Mesuring { get; set; }
        public bool IsValid
        {
            get
            {
                return (!string.IsNullOrEmpty(SerialNumber))
                    && Type.HasValue
                    && OperationOrganization.HasValue
                    && Date.HasValue
                    && BackId.HasValue;
            }
        }
    }
    public class GetSumCar
    {
        public int TotalRows { get; set; }
        public IEnumerable<CarOutput> Rows { get; set; }
    }
}